//
//  AIChargeListCell.m
//  HNBaseProject
//
//  Created by xujie on 2024/7/19.
//

#import "AIChargeListCell.h"

@implementation AIChargeListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}

- (void)createUI {
    self.backgroundColor = [UIColor colorWithHexString:@"#F5F8FB"];
    self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 15, kScreenW-30, 75)];
    self.bgView.layer.cornerRadius = 10;
    self.bgView.layer.masksToBounds = YES;
    self.bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.bgView];
    
    self.nameLab = [[UILabel alloc] init];
    [self.bgView addSubview:self.nameLab];
    self.nameLab.textColor = [UIColor colorWithHexString:@"#000000"];
    self.nameLab.font = PFRFont(15);
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.offset(15);
        make.height.mas_equalTo(21);
    }];
    
    self.timeLab = [[UILabel alloc] init];
    [self.bgView addSubview:self.timeLab];
    
    self.timeLab.font = PFRFont(12);
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(15);
        make.height.mas_equalTo(17);
        make.top.mas_equalTo(self.nameLab.mas_bottom).offset(6);
    }];
    
    self.rightIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"charge_icon"]];
    [self.bgView addSubview:self.rightIcon];
    [self.rightIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.bgView);
        make.right.offset(-15);
    }];
    
    self.countLab = [[UILabel alloc] init];
    [self.bgView addSubview:self.countLab];
    self.countLab.textColor = [UIColor colorWithHexString:@"#1D8EFF"];
    self.countLab.font = PFRFontSemibold(20);
    [self.countLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.bgView);
        make.right.offset(-42);
    }];
    
    self.nameLab.text = @"小袋金币";
    self.timeLab.text = @"2024-07-13 16:45:54";
    self.countLab.text = @"+3000";
}

- (void)reloadCellWithModel:(AIChargeListModel *)model {
    //收支类型1:收入(充值列表传1) 2:支出(消费记录传2)
    self.nameLab.text = model.remark;
    self.timeLab.text = model.createTime;
    if ([model.type isEqualToString:@"1"]) {
        self.countLab.textColor = [UIColor colorWithHexString:@"#1D8EFF"];
        self.countLab.text = [NSString stringWithFormat:@"+%@",model.change_diamond];
    } else {
        self.timeLab.textColor = [UIColor colorWithHexString:@"#000000"];
        self.countLab.text = [NSString stringWithFormat:@"-%@",model.change_diamond];
    }
}


@end
